package com.chenyu.pojo;


import com.chenyu.util.ValidationMath;

import java.io.Serializable;
import java.util.Date;

/**
 * @author Administrator
 * @version 1.0
 * @createDate 2019/6/10 20:02
 * @Description 商品信息类
 */
public class commodityInfo implements Serializable {
    private Integer id;
    private String code;//商品编号
    private String name;
    private Integer price;
    private String description;     //商品描述
    private String commodityType;   //商品类别，分类
    private String colorImg;        //主页图片，多款（比如说手机的正反面照片）
    private String descriptionImg;  //商品明细图片 多个路径用逗号分隔
    private Date putawayDate;       //上架时间

    public Integer getId() {
        return id;
    }

    public commodityInfo setId(Integer id) {
        this.id = id;
        return this;
    }

    public String getCode() {
        return code;
    }

    public commodityInfo setCode(String code) {
        if(null != code && !"".equals(code)){
            code = code.split("'")[1];
        }else{
            code = ValidationMath.getRandomNumber(100000,10000000)+"";
        }
        this.code = code;
        return this;
    }

    public String getName() {
        return name;
    }

    public commodityInfo setName(String name) {
        name = name.split("'")[1];
        this.name = name;
        return this;
    }

    public Integer getPrice() {
        return price;
    }

    public commodityInfo setPrice(Integer price) {
        if(null == price || 0 > price){
            ValidationMath.getRandomNumber(1000);
        }
        this.price = price;
        return this;
    }

    public String getDescription() {
        return description;
    }

    public commodityInfo setDescription(String description) {
        description = description.split("'")[3];
        this.description = description;
        return this;
    }

    public String getCommodityType() {
        return commodityType;
    }

    public commodityInfo setCommodityType(String commodityType) {

        if(null == commodityType || "".equals(commodityType)){
            commodityType = "其他";
        }else{
            commodityType = commodityType.split("'")[1];
        }
        this.commodityType = commodityType;
        return this;
    }

    public String getColorImg() {
        return colorImg;
    }

    public commodityInfo setColorImg(String colorImg) {
        colorImg = colorImg.substring(1,colorImg.length()-1);
        this.colorImg = colorImg;
        return this;
    }

    public String getDescriptionImg() {
        return descriptionImg;
    }

    public commodityInfo setDescriptionImg(String descriptionImg) {
        descriptionImg = descriptionImg.substring(1,descriptionImg.length()-1);
        this.descriptionImg = descriptionImg;
        return this;
    }

    public Date getPutawayDate() {
        return putawayDate;
    }

    public commodityInfo setPutawayDate(Date putawayDate) {
        if(null == putawayDate || "".equals(putawayDate)){
           // putawayDate =
        }
        this.putawayDate = putawayDate;
        return this;
    }

    @Override
    public String toString() {
        return "commodityInfo{" +
                "id=" + id +
                ", code='" + code + '\'' +
                ", name='" + name + '\'' +
                ", price=" + price +
                ", description='" + description + '\'' +
                ", commodityType='" + commodityType + '\'' +
                ", colorImg='" + colorImg + '\'' +
                ", descriptionImg='" + descriptionImg + '\'' +
                ", putawayDate=" + putawayDate +
                '}';
    }
}
